<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<%-- 在欢迎信息后添加管理员入口 --%>
<c:if test="${not empty sessionScope.role and sessionScope.role eq 'admin'}">
    <div style="text-align: center; margin: 10px;">
        <a href="admin.jsp" style="color: green;">进入后台管理</a>
    </div>
</c:if>

<head>
    <title>欢迎使用点餐系统</title>
    <style>
        /* 保持原有 CSS 不变 */
        .menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 20px; }
        .menu-item { border: 1px solid #ddd; padding: 15px; text-align: center; }
        .order-link { display: block; margin-top: 20px; text-align: center; font-size: 18px; }
    </style>
</head>
<body>
<h1 style="text-align:center;">欢迎 ${sessionScope.username}！</h1>

<div class="menu">
    <c:forEach items="${requestScope.dishes}" var="dish">
        <div class="menu-item">
            <h3>${dish.name}</h3>
            <p>价格：￥<fmt:formatNumber value="${dish.price}" pattern="#.00"/></p>
            <form action="OrderServlet" method="post">
                <input type="hidden" name="action" value="add">
                <input type="hidden" name="dishName" value="${dish.name}">
                <input type="hidden" name="price" value="${dish.price}">
                数量：
                <select name="quantity">
                    <c:forEach begin="1" end="10" var="qty">
                        <option value="${qty}">${qty}</option>
                    </c:forEach>
                </select>
                <button type="submit">下单</button>
            </form>
        </div>
    </c:forEach>
</div>

<a href="OrderServlet" class="order-link">查看我的订单</a>
</body>

<body>
<h1 style="text-align:center;">欢迎 ${sessionScope.username}！</h1>
<!-- 添加退出按钮 -->
<div style="text-align: center; margin: 10px;">
    <a href="LogoutServlet" style="color: red; text-decoration: none;">退出登录</a>
</div>

<div class="menu">
    <%-- 其余代码保持不变 --%>
</div>

</html>
